#include "FiveWin.ch"

#define  SS_LEFT   0

//----------------------------------------------------------------------------//

CLASS TSay FROM TControl

   METHOD New( nRow, nCol, cText, oWnd, cPicture, oFont ) CONSTRUCTOR
   METHOD ReDefine( nId, cText, oWnd )   CONSTRUCTOR
   METHOD cToChar() BLOCK { | Self | Super:cToChar( "STATIC" ) }
   METHOD Init( hDlg )

ENDCLASS

//----------------------------------------------------------------------------//

METHOD New( nRow, nCol, cText, oWnd, cPicture, oFont ) CLASS TSay

   local nWidth  := If( oFont != nil, oFont:nWidth,   8 )
   local nHeight := If( oFont != nil, oFont:nHeight, 13 )

   ::nTop     = ( nRow * nHeight ) + 2
   ::nLeft    = nCol * nWidth
   ::nBottom  = ::nTop + nHeight
   
   ::cCaption = If( Empty( cPicture ), cText, Transform( cText, cPicture ) )
   ::nRight   = ::nLeft + Len( ::cCaption ) * nWidth

   ::oWnd     = oWnd
   ::oFont    = oFont
   ::nId      = ::GetNewId()
   ::nStyle   = nOR( WS_CHILD, WS_VISIBLE , SS_LEFT )

   if oWnd:ClassName() != "TDIALOG"
      ::Create( "STATIC" )
   else
      oWnd:DefControl( Self )
   endif

return

//----------------------------------------------------------------------------//

METHOD ReDefine( nId, cText, oWnd, cPicture ) CLASS TSay

   ::nId      = nId
   ::cCaption = cText
   ::cCaption = if( empty( cPicture ), cText, transform( cText, cPicture ) )
   ::oWnd     = oWnd
   ::hWnd     = 0

   oWnd:DefControl( Self )

return

//----------------------------------------------------------------------------//

METHOD Init( hDlg ) CLASS TSay

   Super:Init( hDlg )
   ::cTitle = ::cCaption

   SetWindowText( ::hWnd, ::cCaption )

return

//----------------------------------------------------------------------------//
